Skip to main content

All Questions

0votes
0answers
17views

How to correctly use AddDbContext as scoped and AddDbContextFactory as singleton simultaneously in ASP.NET Core?

I need to use both AddDbContext<MyContext> (scoped) and AddDbContextFactory<MyContext> (singleton) in my ASP.NET Core application. The DbContextFactory will be used in background tasks, ...
Max Bündchen's user avatar
0votes
1answer
37views

Scoped service cannot be consumed in WebApplication builder but works as expected in Host.CreateApplication()

I have am implementing multitenancy using EF Core by referring to some guides online. I implemented the following code as a proof of concept in a console application and it works fine. var builder = ...
Grimson's user avatar
0votes
1answer
111views

Using DI in SaveChangesInterceptor

I have an Entity Framework Core interceptor that has to get some configuration that's declared as so: builder.Services.Configure<AppConfig>(builder.Configuration.GetSection("AppConfig")...
dave's user avatar
0votes
1answer
84views

Injecting scoped service in EF Core DbSet in HotChocolate 15 : Cannot resolve scoped service from root provider

I recently updated my backend GraphQL backend with EF Core and HotChocolate from version 12.x.x to 15.0.3. Build/start works fine. However, I am having trouble querying because the error Unexpected ...
baouss's user avatar
  • 1,940
0votes
0answers
162views

Injecting a Scoped Service into DbContextFactory with Singleton service lifetime when you are using Blazor Server

Thanks to the stackoverflow community I learned that since I'm using ef core with Blazor Server, I must use DbContextFactory because AddDbContext can be problematic, so I add my service as follows ...
Luis Zenteno's user avatar
0votes
0answers
45views

User secrets getting loaded at runtime but not at design time

I'm using IHost to create a service provider in a console app. I have set up user secrets that get loaded when running the project. However when I use the Package Manager Console with commands like ...
iKingNinja's user avatar
0votes
0answers
54views

A second operation was started on this context instance before a previous operation completed within Microservice solution

I'm working on a microservice solution with 20 + services. Each service uses Entity Framework & SQL. I have CrudService that implements standard database operations: public class CrudService<...
Sun's user avatar
  • 4,728
0votes
1answer
106views

Threading Issue with DbContext in Azure Functions Using Cosmos DB Provider, and MediatR

I'm using Entity Framework Core with the Cosmos DB provider in Azure Functions, and when two HTTP-triggered functions are invoked simultaneously, I get an exception stating that the DbContext was ...
Mouayed Bouameur's user avatar
0votes
0answers
43views

Exceptions On Multiple Submission of Form in Blazor EditForm

My Blazor Form works and does valid submission,but when I submit the form multiple times in a very small time interval, it gives different types of exceptions, like: Microsoft.AspNetCore.Components....
user24437316's user avatar
0votes
1answer
46views

Overload Constructor on partial class not called, leading to null reference on DbContext Factory

I have a Entity Framework generated class for one of my context items. (EF8 /.net8 Blazor Server) This class looks like this: // <auto-generated> This file has been auto generated by EF Core ...
bruceiow's user avatar
0votes
0answers
31views

What dependency injection pattern works with shared domain entities using the repository/unit of work pattern

I'm embarking upon a new application framework which will ultimately support many different applications and for each of those applications they will all share a set of common domain entities e.g. ...
Andrew HB's user avatar
1vote
2answers
43views

.Net 6 worker service EF 6 - Repository DI cannot consume scoped service

I have below folder structure in the .Net 6 worker service with EF 6, Solution file(.sln) | |_ Data(.csproj) | |_ Models | | |_ DatadbContext.cs | | | |_ Repository | |_ DbRepository.cs |...
useruser00's user avatar
1vote
1answer
700views

Inject IDbContextFactory<ApplicationDbContext> in a constructor waiting for IDbContextFactory<BaseDbContext>

I'm developing an Asp.Net Core Library intended for use across various microservices within my environment. The primary goal of this library is to standardize the code used for database access. I've ...
M. Ozn's user avatar
  • 1,220
0votes
0answers
44views

DbContext get disposed after Grpc request

I'm learning ASP.NET and I'm trying to build a backend e-commerce management, at this point I have a problem with DbContext DI, right after the Grpc request the db context get disposed and it throw a ...
Xaby's user avatar
0votes
0answers
223views

Trouble with "dotnet run seeddata" when trying to seed a database with EntityFrameworkCore. Specifically with ASP.NET Core 6 Web API

I have been following along with Teddy Smith's ASP.NET Core 6 Web API (although I am using .NET 8.0 since the video is a little old) and PokemonReviewApp is the name of the project (some might be ...
jcthom114's user avatar

153050per page
close